require('../css/commCss/normalize.css')
require('../css/commCss/reset.css')
require('../css/commCss/property.css')
require('../css/commCss/basic.css')
require('animate.css')
const axios = require('axios')
require('weui')
const weui=require('weui.js')
require('../css/landing.less')


document.addEventListener('DOMContentLoaded', function () {
    const iphone = document.querySelector('#iphone')
    const btn = document.querySelector('#btn')
    btn.addEventListener('click', function () {
        if (!/^1[3-9][0-9]{9}$/.test(iphone.value)) {
            errMsg.textContent = '手机号码错误'
            return;
        } else if (!/^[a-zA-Z]\w{5,11}$/.test(pwd.value)) {
            errMsg.textContent = '密码错误'
        } else {
            errMsg.textContent = ''
            axios.post('http://139.9.177.51:8099/users/login', {
                account: iphone.value,
                password: pwd.value
            }).then(function (res) {
                iphone.value = pwd.value = ''
                if (res.data.status == 0) {
                    localStorage.setItem('userId',res.data.data.user.userId)


                    //轻提示：弹出登陆成功框，并跳转网页
                    weui.toast('登陆成功',{
                        duration:1000,
                        callback:function(){
                            location.href = "./home.html"
                        }
                    })
                    
                }
            })
        }

    })

})